/**
 * $Id$ Copyright 2009-2012 Oak Pacific Interactive. All rights reserved.
 */
package com.shuqi.database.model;

import android.text.TextUtils;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import com.shuqi.database.dao.OrmBaseModel;

/**
 * 
 * 
 * @author <a href="mailto:">yaozhen</a>
 * @version 2014-3-7上午9:33:53
 */
@DatabaseTable(tableName = "user_info")
public class UserInfo extends OrmBaseModel {
    
    /**
     * int 类型默认值
     */
    public final static int INT_DEFAULT= -100;

    /** 用户登录状态类型：已登录 */
    public final static int LOGINSTATE_LOGINED = 1;
    /** 用户登录状态类型：未登录 */
    public final static int LOGINSTATE_UNLOGIN = 0;

    /** 用户已验证通过 */
    public final static int USERSTATE_PASSED = 1;
    /** 用户未验证状态 */
    public final static int USERSTATE_UNCHECK = 0;

    /** 账户安全级别：高 */
    public final static int USERSAFELEVEL_HIGH = 1;
    /** 账户安全级别：中 */
    public final static int USERSAFELEVEL_COMMON = 2;
    /** 账户安全级别：低 */
    public final static int USERSAFELEVEL_LOW = 3;

    /** 会员验证通过 */
    public final static int TYPE_CHECKRESULT_VIPUSER_PASSED = 200;

    /** 准会员验证通过 */
    public final static int TYPE_CHECKRESULT_USER_PASSED = 201;
    /** 准会员验证通过:分配新用户 */
    public final static int TYPE_CHECKRESULT_USER_PASSED_NEWUSER = 202;

    /** 验证通过:验证失败，需要重新验证 */
    public final static int TYPE_CHECKRESULT_FAIL_RECHECK = 203;
    /** 验证通过:验证失败 */
    public final static int TYPE_CHECKRESULT_FAIL = 204;

    /** 性别男 */
    public final static int GENDER_MALE = 1;
    /** 性别女 */
    public final static int GENDER_FEMALE = 2;

//    @DatabaseField(generatedId = true)
//    private int _id;

    /** 用户id */
    @DatabaseField(columnName = "user_id", id = true)
    private String userId;

    /** 用户session */
    @DatabaseField(columnName = "session")
    private String session;

    /** 密码 (仅登录时使用) */
    private String password;

    /** 用户昵称 */
    @DatabaseField(columnName = "nike_name")
    private String nickName;

    /** 用户性别：1男，2女 */
    @DatabaseField(columnName = "gender")
    private String gender;

    /** 用户余额：200.5 */
    @DatabaseField(columnName = "balance")
    private String balance ;

    /** 用户绑定的手机号 */
    @DatabaseField(columnName = "mobile")
    private String mobile;

    @DatabaseField(columnName = "email")
    /** 用户绑定的邮箱 */
    private String email;

    /** 用户绑定的新浪微博key */
    @DatabaseField(columnName = "sina_key")
    private String sinaKey;

    /** 可显示的用户绑定的新浪微博昵称 */
    @DatabaseField(columnName = "sina_name")
    private String sinaName;

    /** 当前验证状态（0未验证，1验证通过，2，验证失败） */
    @DatabaseField(columnName = "user_state")
    private int userState = INT_DEFAULT;

    /** 登陆用状态（0表示未登录，1表示已登录) */
    @DatabaseField(columnName = "login_state")
    private int loginState = INT_DEFAULT;

    /** 登录时间13位 */
    @DatabaseField(columnName = "login_time")
    private long loginTime;

    public String getUserId() {
        return userId;
    }

    public String getSession() {
        return session;
    }

    public String getNickName() {
        return nickName;
    }

    public String getGender() {
        return gender;
    }

    public String getBalance() {
        return balance;
    }

    public String getMobile() {
        return mobile;
    }

    public String getEmail() {
        return email;
    }

    public String getSinaKey() {
        return sinaKey;
    }

    public String getSinaName() {
        return sinaName;
    }

    public int getUserState() {
        return userState;
    }

    public int getLoginState() {
        return loginState;
    }

    public long getLoginTime() {
        return loginTime;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public void setSession(String session) {
        this.session = session;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public void setBalance(String balance) {
        this.balance = balance;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public void setSinaKey(String sinaKey) {
        this.sinaKey = sinaKey;
    }

    public void setSinaName(String sinaName) {
        this.sinaName = sinaName;
    }

    public void setUserState(int userState) {
        this.userState = userState;
    }

    public void setLoginState(int loginState) {
        this.loginState = loginState;
    }

    public void setLoginTime(long loginTime) {
        this.loginTime = loginTime;
    }

    public String getMobileShow() {
        if (!TextUtils.isEmpty(mobile)) {
            int len = mobile.length();
            if (len > 7) {
                StringBuffer sb = new StringBuffer(mobile);
                sb.replace(3, 7, "****");
                return sb.toString();
            }
        }
        return mobile;
    }

    /**邮箱不隐藏*/
    public String getEmailShow() {
        return email;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getLoginAccount() {
        String account = !TextUtils.isEmpty(mobile) ? mobile : email;
        return account;
    }

}
